/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gm.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Med EL MOUDDENE
 */
@Entity
@Table(name = "association")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Association.findAll", query = "SELECT a FROM Association a"),
    @NamedQuery(name = "Association.findByIdAssociation", query = "SELECT a FROM Association a WHERE a.idAssociation = :idAssociation")})
public class Association implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_ASSOCIATION")
    private Integer idAssociation;
    @Lob
    @Size(max = 65535)
    @Column(name = "LIBELLE")
    private String libelle;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "association")
    private Collection<InscriptionAssociation> inscriptionAssociationCollection;

    public Association() {
    }

    public Association(Integer idAssociation) {
        this.idAssociation = idAssociation;
    }

    public Integer getIdAssociation() {
        return idAssociation;
    }

    public void setIdAssociation(Integer idAssociation) {
        this.idAssociation = idAssociation;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    @XmlTransient
    public Collection<InscriptionAssociation> getInscriptionAssociationCollection() {
        return inscriptionAssociationCollection;
    }

    public void setInscriptionAssociationCollection(Collection<InscriptionAssociation> inscriptionAssociationCollection) {
        this.inscriptionAssociationCollection = inscriptionAssociationCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAssociation != null ? idAssociation.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Association)) {
            return false;
        }
        Association other = (Association) object;
        if ((this.idAssociation == null && other.idAssociation != null) || (this.idAssociation != null && !this.idAssociation.equals(other.idAssociation))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gm.entities.Association[ idAssociation=" + idAssociation + " ]";
    }
    
}
